package com.ivan.beans;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class ChatUser {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	
	@Persistent
	private String name;
	
	@Persistent
	private String email;
	
	@Persistent
	private String password;

	public ChatUser() {
		super();
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}


	public Long getId() {
		return id;
	}



	public void setId(Long id) {
		this.id = id;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Override
	public boolean equals(Object otherUser) {
		ChatUser other = (ChatUser) otherUser;
		if(other != null && 
				other.getEmail() != null && 
				other.getEmail().equals(this.email)){
			System.out.println("coe...." + other + ", em: " + other.getEmail());
			return true;
		} else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		if(this.email != null){
			return this.email.hashCode();
		} else {
			return super.hashCode();
		}
	}

	@Override
	public String toString() {
		return "ChatUser [id=" + id + ", name=" + name + ", email=" + email
				+ ", password=" + password + "]";
	}
	
}
